﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PssWork1.Model;

namespace PssWork1
{
    public partial class Index : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                using (FAQDBEntities db = new FAQDBEntities())
                {
                    Repeater1.DataSource = db.Topics.ToList();
                    Repeater1.DataBind();
                }
            }
        }

        protected void btnChax_Click(object sender, EventArgs e)
        {
            string wt = TextBox1.Text;
            using (FAQDBEntities db = new FAQDBEntities())
            {
                Repeater1.DataSource = db.Topics.Where(p => p.Title.Contains(wt)).ToList();
                Repeater1.DataBind();
            }
        }

        protected void btnTiw_Click(object sender, EventArgs e)
        {
            Response.Redirect("Question.aspx");
        }

        protected void dj_Command(object sender, CommandEventArgs e)
        {
            int id = Convert.ToInt32(e.CommandArgument);
            Response.Redirect($"AddUpdate.aspx?id={id}");

        }
    }
}